package com.cy.store.controller;

import com.cy.store.pojo.Product;
import com.cy.store.service.IProductService;
import com.cy.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @PROJECT_NAME: store
 * @DESCRIPTION:
 * @USER: 28416
 * @DATE: 2022/11/7 15:40
 */
@RequestMapping("products")
@RestController
public class ProductController extends  BaseController {

    @Autowired
    private  IProductService productController;

    @RequestMapping("/hot_list")
    public JsonResult<List<Product>> getHotList() {
        List<Product> hotList = productController.findHotList();
        return new JsonResult<List<Product>>(OK,hotList);
    }

    @RequestMapping("{id}/details")
    public JsonResult<Product> findById(@PathVariable("id") Integer id){
        Product byId = productController.findById(id);

        return new JsonResult<Product>(OK,byId);
    }

}
